﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Glucometer
{
    public partial class ModeDisplay : UserControl
    {

        public int blinkRate = 2;

        public ModeDisplay()
        {
            InitializeComponent();

            lblUploadingMode.Text = "U";
            lblBrowsingMode.Text = "B";
            lblTestingMode.Text = "T";
            lblErrorMode.Text = "E";

            StopBlinkingAndHideAll();
        }

        public void BlinkComponent(DisplayComponent comp)
        {
            if (comp == DisplayComponent.DEVICE_MODE_BROWSING)
                lblBrowsingMode.startBlinking(blinkRate);
            else if (comp == DisplayComponent.DEVICE_MODE_ERROR)
                lblErrorMode.startBlinking(blinkRate);
            else if (comp == DisplayComponent.DEVICE_MODE_TESTING)
                lblTestingMode.startBlinking(blinkRate);
            else if (comp == DisplayComponent.DEVICE_MODE_UPLOADING)
                lblUploadingMode.startBlinking(blinkRate);                 
        }

        public void ShowComponent(DisplayComponent comp)
        {
            if (comp == DisplayComponent.DEVICE_MODE_BROWSING)
                lblBrowsingMode.Visible = true;
            else if (comp == DisplayComponent.DEVICE_MODE_ERROR)
                lblErrorMode.Visible = true;
            else if (comp == DisplayComponent.DEVICE_MODE_TESTING)
                lblTestingMode.Visible = true;
            else if (comp == DisplayComponent.DEVICE_MODE_UPLOADING)
                lblUploadingMode.Visible = true;
        }

        public void StopBlinkingAndHideAll()
        {
            lblBrowsingMode.stopBlinking();
            lblErrorMode.stopBlinking();
            lblTestingMode.stopBlinking();
            lblUploadingMode.stopBlinking();

            ShowAll(false);
        }

        private void ShowAll(bool visible)
        {
            lblBrowsingMode.Visible =
                lblErrorMode.Visible =
                lblTestingMode.Visible =
                lblUploadingMode.Visible = visible;
        
        }

    }
}
